<template>
	<view>
		<!-- 地址列表 -->
		<card headTitle="收货地址" bodyStyle="background:#ffffff;">
			<uni-list-item 
				v-for="(address, index) in addressList" 
				:key="index" 
				:title="address.name" 
				:note="`${address.phone} | ${address.address}`"
				showArrow 
				@click="editAddress(address.id)"
			></uni-list-item>
		</card>

		<!-- 添加新地址按钮 -->
		<view class="p-3">
			<button type="primary" class="bg-white" @click="addAddress">添加新地址</button>
		</view>
	</view>
</template>

<script>
	import card from "@/components/common/card.vue";
	import uniListItem from '@/components/uni-ui/uni-list-item/uni-list-item.vue';

	export default {
		components: {
			card,
			uniListItem
		},
		data() {
			return {
				addressList: [
					{
						id: 1,
						name: "张三",
						phone: "13800138000",
						address: "北京市朝阳区某某街道123号"
					},
					{
						id: 2,
						name: "李四",
						phone: "13900139000",
						address: "上海市浦东新区某某路456号"
					}
				] // 模拟地址数据
			};
		},
		methods: {
			// 编辑地址
			editAddress(id) {
				uni.navigateTo({
					url: `/pages/address-edit/address-edit?id=${id}`
				});
			},
			// 添加新地址
			addAddress() {
				uni.navigateTo({
					url: "/pages/address-edit/address-edit"
				});
			}
		}
	};
</script>

<style>
	page {
		background: #EEEEEE;
	}

	.p-3 {
		padding: 20rpx;
	}

	button.bg-white {
		background-color: #FFFFFF;
		color: #333333;
		border: 1px solid #DDDDDD;
		border-radius: 50rpx;
		font-size: 32rpx;
		height: 80rpx;
		line-height: 80rpx;
	}
</style>